package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TCkOrders;
import com.ruoyi.system.service.ITCkOrdersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出库单表Controller
 * 
 * @author ruoyi
 * @date 2024-09-04
 */
@RestController
@RequestMapping("/system/chuku/orders")
public class TCkOrdersController extends BaseController
{
    @Autowired
    private ITCkOrdersService tCkOrdersService;

    /**
     * 查询出库单表列表
     */
    @PreAuthorize("@ss.hasPermi('system:orders:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCkOrders tCkOrders)
    {
        startPage();
        List<TCkOrders> list = tCkOrdersService.selectTCkOrdersList(tCkOrders);
        return getDataTable(list);
    }

    /**
     * 导出出库单表列表
     */
    @PreAuthorize("@ss.hasPermi('system:orders:export')")
    @Log(title = "出库单表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCkOrders tCkOrders)
    {
        List<TCkOrders> list = tCkOrdersService.selectTCkOrdersList(tCkOrders);
        ExcelUtil<TCkOrders> util = new ExcelUtil<TCkOrders>(TCkOrders.class);
        util.exportExcel(response, list, "出库单表数据");
    }

    /**
     * 获取出库单表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:orders:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") String orderId)
    {
        return success(tCkOrdersService.selectTCkOrdersByOrderId(orderId));
    }

    /**
     * 新增出库单表
     */
    @PreAuthorize("@ss.hasPermi('system:orders:add')")
    @Log(title = "出库单表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCkOrders tCkOrders)
    {
        return toAjax(tCkOrdersService.insertTCkOrders(tCkOrders));
    }

    /**
     * 修改出库单表
     */
    @PreAuthorize("@ss.hasPermi('system:orders:edit')")
    @Log(title = "出库单表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCkOrders tCkOrders)
    {
        return toAjax(tCkOrdersService.updateTCkOrders(tCkOrders));
    }

    /**
     * 删除出库单表
     */
    @PreAuthorize("@ss.hasPermi('system:orders:remove')")
    @Log(title = "出库单表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable String[] orderIds)
    {
        return toAjax(tCkOrdersService.deleteTCkOrdersByOrderIds(orderIds));
    }
}
